package com.cola.ui;

import com.cola.utils.BussinessException;
import com.cola.utils.UserIO;
import org.junit.jupiter.api.Test;

/**
 * @Grup:com.cola.ui
 * @Auther:cola
 * @Data:2021/4/13-2021-04-16:40
 * @version:1.0
 */
public class WelcomeClass extends BaseClass {

    public void start(){
        println(getString("info.welcome"));
        boolean flag=true;
        while (flag){
            println(getString("info.login.reg"));
            println(getString("info.select"));
            String select = input.nextLine();
            switch (select){
                case "1":
                    System.out.println("登录");
                    try {
                        new LoginClass().login();
                        flag=false;
                        println(getString("login.success"));
                    } catch (BussinessException e) {
                        println(getString("login.error"));
                    }
                    break;
                case "2":
                    System.out.println("注册");
                    try {
                        new RegisterClass().register();
                        println(getString("reg.success"));
                        flag=false;
                    } catch (BussinessException e) {
                        println(getString("reg.error"));
                    }
                    break;
                default:
                    println(getString("input.error"));
                    break;
            }
        }
        HomeClass homeClass = new HomeClass();
        homeClass.show();
    }
}
